package com.dinzeer.legendreliclib.lib.util.slashblade;

import mods.flammpfeil.slashblade.capability.slashblade.ISlashBladeState;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import mods.flammpfeil.slashblade.registry.specialeffects.SpecialEffect;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraftforge.registries.RegistryObject;


public class SlashBladeUtil {
    //获取state
    public static final Capability<ISlashBladeState> state= ItemSlashBlade.BLADESTATE;
    public static ISlashBladeState getState(ItemStack stack) {
        return stack.getCapability(state).resolve()
                .orElseThrow(() -> new IllegalStateException("ItemStack 缺失 ISlashBladeState 能力"));
    }

    public static boolean hasSpecialEffect(ItemStack stack, RegistryObject<SpecialEffect> effect) {
        if (stack.getCapability(state).isPresent()){
        return getState(stack).hasSpecialEffect(effect.getId());
        }else {return false;}
    }
    //获取杀敌数
    public static int getKillCount(ItemStack stack) {
        if (stack.getCapability(state).isPresent()){
        return getState(stack).getKillCount();
        }else {return 0;}
    }
    //获取耀魂数
    public static int getproudSoul(ItemStack stack) {

        return getState(stack).getProudSoulCount();
    }
    //获取锻造数
    public static int getRefine(ItemStack stack) {
        return getState(stack).getRefine();
    }
    //获取最大耐久
    public static int getMaxDamge(ItemStack stack) {
        return getState(stack).getMaxDamage();
    }
    //获取刀自身面板
    public static float getBaseAttackModifier(ItemStack stack) {
        return getState(stack).getBaseAttackModifier();
    }
    //获取刀的本地化名称
    public static String getTranslationKey(ItemStack stack) {
        return getState(stack).getTranslationKey();
    }
    //获取刀的刀光颜色
    public static int getColorCode(ItemStack stack) {
        return getState(stack).getColorCode();
    }
}
